#coding=utf-8
import unittest
from selenium import webdriver
from appium import webdriver
from time import sleep
from nav_plugin_op import nav_plugin_factory
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.support.ui import WebDriverWait
import os
from Public import BasePage
from Tool.usefulTools import userfulToolsFactory
from Public.BasePage import element_Oprate
from Public.BasePage import BasicAction

navOpenFactory = nav_plugin_factory()
userfulTool = userfulToolsFactory()
element_oprate_instance = element_Oprate()
basicAction = BasicAction()

# nav_name = "工作"
# plugin_name = "案件处置"
nav_name = ["导航栏工作",'xpath',"//android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.FrameLayout/android.widget.RadioButton"]
plugin_name = ["插件列表-监督员配置",'name','监督员配置']

class supervisor_allocation_factory():

	def open_supervisor_allocation_plug(self,driver,file_path):
		try:
			element_oprate_instance.element_click(nav_name,file_path)
			driver.swipe(400,1000,400,50,1200)
			sleep(2)
			element_oprate_instance.element_click(plugin_name,file_path)
			driver.implicitly_wait(15)
			if driver.find_element_by_name("责任网格".decode("utf-8")).is_displayed():
				print("supervisor allocation success.....")
				driver.get_screenshot_as_file(file_path + "//open_supervisor_allocation_successful.png")
			else:
				print("open supervisor  allocation failed.....")

		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//open_supervisor_allocation_fail.png")
			raise

if __name__ == '__main__':
	unittest.main()